#include "tlib_shm.h"

int main( int argc, char *argv[] )
{
	int nRc;
	char *pContent;
	int  nContentLen;
	
	tagShmHandle  ShmHandle;
	
	
	if ( argc < 2 )
	{
		printf( "Usage: shm_test [c | d | g ContentName].\n" );
		return 0;
	}
	
	if ( *(argv[1]) == 'c' )
	{
		nRc = tlib_shm_Create( "/usr/local/comm/tlib/tlib_shm/example/shm.conf" );
		
		printf( "nRc is %d\n", nRc );
	}
	else if ( *(argv[1]) == 'd' )
	{	
		nRc = tlib_shm_Destroy( "/usr/local/comm/tlib/tlib_shm/example/shm.conf" );
		
		printf( "nRc is %d\n", nRc );
	}
	else if ( *(argv[1]) == 'g' )
	{
		nRc = tlib_shm_Open( "/usr/local/comm/tlib/tlib_shm/example/shm.conf", &ShmHandle );		
		printf( "tlib_shm_Open return %d\n", nRc );
		
		nRc = tlib_shm_Get( &ShmHandle, argv[2], C_SHM_GET_OPTION_COPY, &pContent, &nContentLen );
		printf( "tlib_shm_Get return %d\npContent :\n%s\nnContentLen : %d\n", nRc, pContent, nContentLen );
		//printf( "tlib_shm_Get return %d\nnContentLen : %d\n", nRc, nContentLen );
		//free( pContent );
		
		tlib_shm_Dump( &ShmHandle );
		
		nRc = tlib_shm_Close( &ShmHandle );

		printf( "tlib_shm_Close return %d\n", nRc );
		
	}
			
}
